package com.problem.leetcode;

import java.util.HashSet;

/**
 * @author didi
 * @DESCRIPTION
 * @create 2019-05-02 16:45
 **/

public class Problem773 {
    public int numJewelsInStones(String J, String S) {
        HashSet<Character> hashSet = new HashSet<>();
        for (int index = 0; index < J.length(); index++) {
            hashSet.add(J.charAt(index));
        }

        int count = 0;
        for (int index = 0; index < S.length(); index++) {
            if (hashSet.contains(S.charAt(index))) {
                ++count;
            }
        }
        return count;
    }
}
